<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="common">
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="bigbox"></div>
<form id="myfrom">
<input id="inp1">a
<input id="inp2">b
    <a onclick="sendForm()">发送</a>
    <a onclick="sendForm2()">发送2</a>
</form>
</body>
<script>
    //提交消息1
    function sendForm(){
        $.ajax({
            url:"/home/sendForm",
            data:{info1:$("#inp1").val()},
            success:function(){
                $("#inp1").val("");
            }
        })
    }
    setInterval(getmessage,1000);
    //查询消息
    function getmessage(){
        $.ajax({
            url:"/home/getMess",
            success:function(data){
               console.log(data)
                if(data!=''){
                    var str = "<span>a:"+data+"</span><br>"
                    $("#bigbox").append(str);
                }
            }
        })
    }
    //提交消息2
    function sendForm2(){
        $.ajax({
            url:"/home/sendForm2",
            data:{info2:$("#inp2").val()},
            success:function(){
                $("#inp2").val("");
            }
        })
    }
    setInterval(getmessage2,1000);
    //查询消息
    function getmessage2(){
        $.ajax({
            url:"/home/getMess2",
            success:function(data){
                if(data!=''){
                    var str = "<span>b:"+data+"</span><br>"
                    $("#bigbox").append(str);
                }
            }
        })
    }
</script>
</html>